z = input().split()
s = {"zero": "0", "one": "1", "two": "2", "three": "3", "four": "4", "five": "5", "six": "6", "seven": "7",
     "eight": "8", "nine": "9"}
mem = ""
t = True
x1 = -1
x2 = -1
if len(z) == 3:
    for i in z:
        if i in s:
            mem += s[i]
        else:
            print("Wrong input")
            t = False
            break
    if t:
        mem = int(mem)
        for i in range(mem, mem * 2):
            k = True
            for i1 in range(2, i // 2 + 1):
                if i % i1 == 0:
                    k = False
            if k:
                x1 = i
                break
        for i in range(mem, 0, -1):
            k = True
            for i1 in range(2, i // 2 + 1):
                if i % i1 == 0:
                    k = False
            if k:
                x2 = i
                break
        if x1 - mem == mem - x2:
            print(x2)
        elif x1 - mem < mem - x2:
            print(x1)
        elif x1 - mem > mem - x2:
            print(x2)
else:
    print("Wrong input")
